#include("../layout.html")
#@layout("阅读设置")

#define body()
<h1>阅读设置</h1>

<div class="layui-fluid">
	<form class="layui-form" action="/admin/option/reading" method="post">
    	<div class="layui-form-item">
    		<input type="hidden" id="show_on_front" value="#(show_on_front??)" />
    		<label class="layui-form-label">您的主页显示</label>
    		<div class="layui-input-block">
    			<input type="radio" name="show_on_front" value="posts" title="您的最新文章" checked="checked" lay-filter="front">
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="radio" name="show_on_front" value="page" title="一个静态页面（在下方选择）" lay-filter="front">
   	 		</div>
   	 		<div class="layui-input-block">
   	 			主页：
   	 			<div class="layui-inline">
	   	 			<select name="page_on_front" id="page_on_front" data="#(page_on_front??)" disabled="disabled">
	   	 				<option>—选择—</option>
	   	 			</select>
   	 			</div>
   	 		</div>
   	 		<div class="layui-input-block">
   	 			文章页：
   	 			<div class="layui-inline">
	   	 			<select name="page_for_posts" id="page_for_posts" data="#(page_for_posts??)" disabled="disabled">
	   	 				<option>—选择—</option>
	   	 			</select>
   	 			</div>
   	 		</div>
    	</div>
    	<div class="layui-form-item">
    		<label class="layui-form-label">博客页面至多显示</label>
    		<div class="layui-input-block">
    			<div class="layui-inline" style="width:80px;">
    				<input type="number" name="posts_per_page" id="posts_per_page" value="#(posts_per_page??)" placeholder="" autocomplete="off" class="layui-input">
    			</div>
    			篇文章
   	 		</div>
    	</div>
    	<div class="layui-form-item">
    		<label class="layui-form-label">Feed中显示最近</label>
    		<div class="layui-input-block">
    			<div class="layui-inline" style="width:80px;">
    				<input type="number" name="posts_per_rss" id="posts_per_rss" value="#(posts_per_rss??)" placeholder="" autocomplete="off" class="layui-input">
    			</div>
    			个项目
   	 		</div>
    	</div>
    	<div class="layui-form-item">
    		<input type="hidden" id="rss_use_excerpt" value="#(rss_use_excerpt??)" />
    		<label class="layui-form-label">对于feed中的每篇文章，显示</label>
    		<div class="layui-input-block">
    			<input type="radio" name="rss_use_excerpt" value="0" title="全文">
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="radio" name="rss_use_excerpt" value="1" title="摘要">
   	 		</div>
    	</div>
		<div class="layui-form-item">
    		<label class="layui-form-label">对搜索引擎的可见性</label>
    		<div class="layui-input-block">
    			<input type="checkbox" name="blog_public" id="blog_public" value="#(blog_public??)" value="0" title="建议搜索引擎不索引本站点" lay-skin="primary"> 
   	 		</div>
   	 		<div class="layui-input-block">
   	 			<p class="description">搜索引擎将本着自觉自愿的原则对待WordPress提出的请求。并不是所有搜索引擎都会遵守这类请求。</p>
   	 		</div>
    	</div>
    	<div class="layui-form-item">
    		<button type="submit" lay-submit lay-filter="*" class="layui-btn layui-btn-sm">保存更改</button>
    	</div>
    </form>
</div>
#end

#define foot()
<script>
layui.cache.page = 'option';
layui.use('tbynet', function(){
	var $ = layui.$
	,form = layui.form
	,tbynet = layui.tbynet;
	
	form.on('radio(front)', function(data){
		if('page' == data.value) {
			$('#page_on_front').attr('disabled', false);
			$('#page_for_posts').attr('disabled', false);
		} else {
			$('#page_on_front').attr('disabled', true);
			$('#page_for_posts').attr('disabled', true);
		}
		form.render();
	});
	
	if('page' == $('#show_on_front').val()) {
		$('#page_on_front').attr('disabled', false);
		$('#page_for_posts').attr('disabled', false);
	} else {
		$('#page_on_front').attr('disabled', true);
		$('#page_for_posts').attr('disabled', true);
	}
	
	$('input[name=show_on_front]').each(function(i, e){
		if($(e).val() == $('#show_on_front').val()) {
			$(e).prop('checked', true);
	    } else {
	    	$(e).prop('checked', false); 
	    }
	});
	
	$('input[name=rss_use_excerpt]').each(function(i, e){
		if($(e).val() == $('#rss_use_excerpt').val()) {
			$(e).prop('checked', true);
	    } else {
	    	$(e).prop('checked', false); 
	    }
	});
	
	$('#page_on_front').val($('#page_on_front').attr('data'));
	$('#page_for_posts').val($('#page_for_posts').attr('data'));
	
	form.render();
});
</script>
#end